<?php
require('../setting.php');
$version = $system_pz['system_version'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>版本更新</title>
    <style>
        body {
            font-family: 'SF Pro Display', 'SF Pro Text', 'SF Pro Icons', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
            background-color: #f0f4f8;
            margin: 0;
            padding: 50px;
            color: #333;
        }

        .update-container {
            width: 350px;
            margin: 0 auto;
            text-align: center;
            background-color: #ffffff;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        h1 {
            color: #1a56f0;
            font-size: 24px;
            margin-bottom: 20px;
        }

        p {
            color: #666;
            font-size: 16px;
            margin-bottom: 15px;
        }

        button {
            margin-top: 10px;
            padding: 12px 25px;
            background-color: #1a56f0;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s ease;
            font-size: 16px;
        }

        button:hover {
            background-color: #163d8d;
        }

        button:active {
            background-color: #1a56f0;
        }
    </style>
</head>
<body>
    <div class="update-container">
        <h1>版本更新</h1>
        <p id="current-version">当前版本: <span id="version-number"></span></p>
        <h3><?php echo $system_pz['system_msg'] ?></h3>
        <button id="manual-update">手动更新</button>
        <button id="check-update">远程更新</button>
    </div>
</body>
</html>
<script>
    document.getElementById('check-update').addEventListener('click', function() {
    checkForUpdate();
});

document.getElementById('manual-update').addEventListener('click', function() {
    window.open('https://www.123pan.com/s/WsQ0Vv-LWmUA.html', '_blank');
});
var version = <?php echo json_encode($version); ?>;
document.getElementById('current-version').innerText = '当前版本：'+version;
function checkForUpdate() {
    if(!confirm('是否检查版本-更新?更新途中，不要离开本页面，否则可能会更新失败')){
        return false;
    }
    document.getElementById('check-update').style.visibility = 'hidden';
    fetch('../cofd/check.php?version='+version)
        .then(response => response.json())
        .then(data => {
           if(data.status === 1){
            document.getElementById('current-version').innerText = data.msg;
           }else{
            document.getElementById('current-version').innerText = data.msg;
           }
           document.getElementById('check-update').style.visibility = 'visible';
        })
        .catch(error => console.error('Error fetching latest version:', error));
}


</script>